import logging
import psutil

from flask import Blueprint, request, current_app
from app.utils.response import ResMsg
from app.utils.util import route
from app.utils.ResponseUtil import ResponseCode

info_ml = Blueprint("info", __name__, url_prefix='/info')
logger = logging.getLogger(__name__) # 返回一个新的以文件名为名的logger

@route(info_ml, '/getMemoryUsed', methods=['GET', 'POST'])
def get_memory_used():
    """
    获取服务器内存使用的状况
    """
    data = psutil.virtual_memory()
    result_dict = {}
    result_dict["used"] = data.percent
    res = ResMsg(code=ResponseCode.Success, data = result_dict)

    return res.data